import 'package:flutter/material.dart';
import 'package:tdesign_flutter/tdesign_flutter.dart';
import 'package:toys_flutter/components/AgeSpan.dart';
import 'package:toys_flutter/components/AuthSpan.dart';
import 'package:toys_flutter/components/LevelSpan.dart';
import 'package:toys_flutter/components/MyAvatarWidget.dart';

class UserInfo extends StatelessWidget {
  final Map<String, dynamic>? user;
  const UserInfo({super.key, this.user});

  @override
  Widget build(BuildContext context) {
    if (user == null) {
      return const SizedBox(height: 30); // 返回一个空的占位符
    }
    return ListTile(
      contentPadding: const EdgeInsets.symmetric(horizontal: 0), // 设置左右内边距
      leading: MyAvatarWidget(image: user!['avatar'] ?? 'images/avatar.png', imageWidth: 50,),
      // leading: TDAvatar(
      //   avatarUrl: user!['avatar'] ?? 'images/avatar.png',
      // ),
      title: Row(
        children: [
          Text(user!['nickname']),
          const SizedBox(width: 5),
          LevelSpan(level: user!['level'].toString()),
          const SizedBox(width: 5),
          const AuthSpan()
        ],
      ),
      subtitle: Row(
        children: [
          const SizedBox(height: 30),
          AgeSpan(gender: user!['sex'].toString(), age: user!['age'].toString())
        ],
      ),
    );
  }
}
